package com.yundong.gongchengji.util;

import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;

public class WindowManagerUtils {

	/**
	 * 把某个view设置成全屏大小
	 * 
	 * @param context
	 * @param view
	 */
	public static void toMath(Activity context, View view) {
		DisplayMetrics dm = new DisplayMetrics();
		// 获取屏幕信息
		context.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenWidth = dm.widthPixels;
		int screenHeigh = dm.heightPixels;
		ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
		layoutParams.height = screenHeigh;
		layoutParams.width = screenWidth;
		view.setLayoutParams(layoutParams);
	}

	/**
	 * 获取屏幕的高度
	 * @param context
	 * @return
     */
	public static int getWindowHeight(Activity context) {
		DisplayMetrics dm = new DisplayMetrics();
		// 获取屏幕信息
		context.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenHeigh = dm.heightPixels;
		return screenHeigh;
	}

	/**
	 * 获取屏幕的宽度
	 * @param context
	 * @return
     */
	public static int getWindowWidth(Activity context) {
		DisplayMetrics dm = new DisplayMetrics();
		// 获取屏幕信息
		context.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenWidth = dm.widthPixels;
		return screenWidth;
	}

	/**
	 * 返回到点击之前的大小
	 * 
	 * @param view
	 * @param height
	 *            之前的高度
	 * @param width
	 *            之前的宽度
	 */
	public static void toReturn(View view, int height, int width) {
		ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
		layoutParams.height = height;
		layoutParams.width = width;
		view.setLayoutParams(layoutParams);
	}
}
